# !/bin/bash

set -e

cd $( dirname ${BASH_SOURCE[0]} )
APP_CONTAINER_NAME="courier_repchain-block-courier"
VERSION=$(sed -n 's/^\s*version\s*=\s*\(.*\)\s*/\1/p' .release)
IMAGE="repchain_block_courier:${VERSION}"

cd ../..

docker stop "${APP_CONTAINER_NAME}"
docker rm "${APP_CONTAINER_NAME}" 

docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ${PWD}/config:/usr/app/repchain-block-courier/config \
"${IMAGE}" bash -c "yarn stop:containers"

echo "Stopped"
